/*
 * Copyright (c) 2017 22420103@QQ.COM 版权所有
 *
 */

jQuery(function($) {
	loadData();
});

function loadData(){
	var data = $("#menuQueryForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#context").html(data);
		}
	});
}

function seeDetail(id){
    window.location.href = 'modifyMenu?id=' + id;
}

function addMenu() {
	window.location.href = 'addMenu';
}

function delMenu(id) {

    parent.window.Index.dialog({
        resizable: false,
        dialogClass: "no-close",
        width: '620',
        context:$("#delMenuDialog").html(),
        modal: true,
        title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa yellow'></i>删除菜单确认</h4></div>",
        title_html: true,
        buttons: [
            {
                html: "<i class='ace-icon glyphicon glyphicon-ok bigger-110'></i>&nbsp; 确认",
                "class" : "btn btn-primary btn-minier",
                click: function() {
                    var key = parent.window.$("#key").val();
                    if(key == "" ){
                        parent.window.$("#promptTxt").html("请输入授权码");
                        return;
                    }
                    if(id == ""){
                        parent.window.$("#promptTxt").html("请输入菜单ID");
                        return;
                    }
                    var finalThis = this;
                    $.ajax({
                        type:"POST",
                        url:"delMenu",
                        data:"id="+id+"&key="+key,
                        cache:false,
                        dataType:"json",
                        success:function(data){
                            if(data.code == 1){
                                parent.window.$(finalThis).dialog( "close" );
                                window.location.href=ctx+"/admin/systemManager/menuManager";
                            }else{
                                parent.window.$("#promptTxt").html("温馨提示：" + data.msg);
                            }
                        }
                    });
                }
            }
            ,
            {
                html: "<i class='ace-icon glyphicon glyphicon-remove bigger-110'></i>&nbsp; 取消",
                "class" : "btn btn-minier",
                click: function() {
                    parent.window.$( this ).dialog( "close" );
                }
            }
        ]
    });

    /*$.ajax({
        type:"POST",
        url:"delMenu",
        data:"id="+id,
        cache:false,
		dataType:"json",
        success:function(data){
            if(data.code == "1"){
                window.location.href=ctx+"/admin/systemManager/menuManager";
            }else {
                alert("温馨提示：" + data.msg);
            }
        }
    });*/

}
